12. CODE: Initialize the Open Vector

Initialize the Open Vector

Filling out the `Search()` function

Filling out the Search() function

Fantastic work so far! In the last few coding exercises, you've been writing helper functions that will be used in the A* search. While there are a few more helper functions that still need to be written, in this exercise, you will begin implementing the body of the Search function. In particular, you will take the arguments that are passed to the search function, get the x, y, g, and h values for the first node, and then add the first node to the open vector.

We have provided the empty vector of open nodes, open, in the Search function for you to use.

To Complete This Exercise:

  1. Initialize variables with the starting node values as follows:
  • x and y are given by the init variable values,
  • Set the initial cost g = 0,
  • h is given by Heuristic function.
  1. Add first node to open vector using the AddToOpen function by passing the node values: x, y, g, and h, along with the open and grid vectors.

Workspace

This section contains either a workspace (it can be a Jupyter Notebook workspace or an online code editor work space, etc.) and it cannot be automatically downloaded to be generated here. Please access the classroom with your account and manually download the workspace to your local machine. Note that for some courses, Udacity upload the workspace files onto https://github.com/udacity, so you may be able to download them there.

Workspace Information:

  • Default file path:
  • Workspace type: generic
  • Opened files (when workspace is loaded): n/a
  • userCode:

    export CXX=g++-7
    export CXXFLAGS=-std=c++17
    g++() {
    /usr/bin/g++-7 -std=c++17 "$1"
    }
    export -f g++